<template>
<!-- 仓库审核 -->
  <div id="storageReview">
<!--    <el-form :inline="true" :model="formInline" class="demo-form-inline">-->
<!--      <el-form-item label="仓库名">-->
<!--        <el-input v-model="formInline.user" placeholder="请输入仓库名"></el-input>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="仓库类型">-->
<!--        <el-select v-model="formInline.region" placeholder="请选择">-->
<!--          <el-option label="普通仓库" value="shanghai"></el-option>-->
<!--          <el-option label="冷藏仓库" value="beijing"></el-option>-->
<!--        </el-select>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="审核进度">-->
<!--        <el-select v-model="formInline.region" placeholder="请选择">-->
<!--          <el-option label="审核通过" value="shanghai"></el-option>-->
<!--          <el-option label="驳回申请" value="beijing"></el-option>-->
<!--        </el-select>-->
<!--      </el-form-item>-->
<!--      <el-form-item>-->
<!--        <el-button icon="el-icon-search" type="" @click="search" round type="primary">查询</el-button>-->
<!--      </el-form-item>-->
<!--    </el-form>-->
    <el-table :data="StorageFuheAry" style="width: 100%">
      <el-table-column prop="warehouseId" label="编号" width="180">
      </el-table-column>
      <el-table-column prop="warehouseName" label="仓库名称" width="180">
      </el-table-column>
      <el-table-column prop="name" label="仓库类型">
      </el-table-column>
      <el-table-column prop="register" label="登记人">
      </el-table-column>
      <el-table-column prop="registerTime" label="登记时间">
      </el-table-column>
      <el-table-column prop="checkTag" label="审核状态">
        <template slot-scope="scope">
          <span v-if="scope.row.checkTag=='S001-1'" style="color: #409eff">等待审核</span>
          <span v-if="scope.row.checkTag=='S001-2'" style="color:#F56C6C">审核未通过</span>
          <span v-if="scope.row.checkTag=='S001-3'" style="color:#67C23A">审核通过</span>
        </template>
      </el-table-column>
      <!--操作列-->
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
              size="small"
              type="warning"
              round
              icon=""
              v-if="showButton(scope.row.checkTag)"
              @click="FuheStorage(scope.$index,scope.row)">复核</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!---分页组件-->
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="pageSizeList"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
    </el-pagination>
    <!--复核对话框-->
    <el-dialog title="安全库存配置单复核" :visible.sync="addFormVisible">
      <el-form :model="StorageFuhe">
        <el-form-item label="编号" :label-width="formLabelWidth">
          <el-input v-model="StorageFuhe.warehouseId" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="仓库名称" :label-width="formLabelWidth">
          <el-input v-model="StorageFuhe.warehouseName" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="仓库类型" :label-width="formLabelWidth">
          <el-input v-model="StorageFuhe.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="登记人" :label-width="formLabelWidth">
          <el-input v-model="StorageFuhe.register" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="登记时间" :label-width="formLabelWidth">
          <el-input v-model="StorageFuhe.registerTime" autocomplete="off"></el-input>
        </el-form-item>
<!--        <el-form-item label="审核状态" :label-width="formLabelWidth">-->
<!--          <el-input v-model="StorageFuhe.checkTag" autocomplete="off"></el-input>-->
<!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="fuhenoCell">驳回申请</el-button>
        <el-button type="primary" @click="fuheCell">通过审核</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "StorageReview",
  data() {
    return{
      //对话框回显
      StorageFuhe:{},
      //审核对话框展示
      addFormVisible:false,
      //仓库审核表格
      StorageFuheAry:[],
      formInline: {
        user: '',
        region: ''
      },
      // 当前页号
      currentPage: 1,
      // 当前页大小
      pageSize: 5,
      // 总记录数
      total: 0,
      // 页大小列表
      pageSizeList: [2, 5, 10, 20]
    }
  },
  methods:{
    //复核通过
    async fuheCell(){
      const {data: res} = await this.$http.post(`/warehouse/fuhewarehouseById/`,this.StorageFuhe)
      this.addFormVisible=false
      //消息提示
      this.$message({
        showClose: true,
        message: '复核成功',
        type: 'success'
      });
      this.StorageFuhePage()
      },
      //复核不通过
    async fuhenoCell(){
      const {data: res} = await this.$http.post(`/warehouse/fuhenowarehouseById/`,this.StorageFuhe)
        this.addFormVisible=false
        //消息提示
        this.$message({
          showClose: true,
          message: '操作成功',
          type: 'success'
        });
        this.StorageFuhePage()
      },
    // 显示添加对话框
		async FuheStorage(index,row) {
				  // 清空绑定对象
				  this.addForm = {}
				  // 显示对话框
				  this.addFormVisible = true
          const {data: res} = await this.$http.post(`/warehouse/updwarehouseById/${row.warehouseId}`)
          this.StorageFuhe = res
				},
    onSubmit() {
      console.log('submit!');
    },
    // 页大小改变
    handleSizeChange(val) {
      this.pageSize = val
      this.StorageFuhePage()
    },

    // 页号改变
    handleCurrentChange(val) {
      this.currentPage = val
      this.StorageFuhePage()
    },
    //分页查询安全库存配置单数据
    async StorageFuhePage(){
      const {data: res} = await this.$http.post(`/warehouse/WarehouseFuhePage/
				${this.currentPage}/${this.pageSize}`, this.searchObj)
      console.log(res);
      this.StorageFuheAry =res.list
      this.total =res.total
    },
    showButton(tag){
      if (tag=='S001-3'){
        return false
      }
      return true
    }
  },
  created() {
    this.StorageFuhePage()
  }
}
</script>

<style scoped>

</style>